package org.mozhu.mysql.learning.hitcounter;

import org.springframework.stereotype.Service;

import java.util.concurrent.atomic.AtomicInteger;

@Service("JVMHitCounterService")
public class JVMHitCounterService implements HitCounterService {

    private AtomicInteger counter = new AtomicInteger();

    public JVMHitCounterService(){
        System.out.println("JVMHitCounterService init");
    }
    @Override
    public void increase() {
        counter.getAndIncrement();
    }

    @Override
    public int count() {
        return counter.get();
    }

    @Override
    public void reset() {
        counter.set(0);
    }
}
